CREATE LOGIN test WITH PASSWORD = 'test'
CREATE USER test FOR LOGIN test

CREATE LOGIN test2 WITH PASSWORD = 'test2'
CREATE USER test2u FOR LOGIN test2

GRANT SELECT 
	ON PASSPORT
	TO test
WITH GRANT OPTION

GRANT TAKE OWNERSHIP TO test
ALTER AUTHORIZATION ON DATABASE::lab3 TO test
EXEC sp_changedbowner @loginame='test'

GRANT SELECT, INSERT, UPDATE 
	ON PERSON 
	TO test
GRANT SELECT (tour_id, price, discount) 
	ON [GROUP] 
	TO test
GRANT UPDATE (price, discount) 
	ON [GROUP] 
	TO test
GRANT SELECT 
	ON MAIN_FEATURE 
	TO test
GRANT SELECT 
	ON homeland
	TO test

CREATE ROLE test_role 
GRANT UPDATE (sea, hotel)
	ON place
	TO test_role
EXEC sp_addrolemember 'test_role', 'test'

GRANT CONNECT TO test
GRANT CONNECT TO test2u
REVOKE CONNECT TO test

SELECT SUSER_NAME(), USER_NAME();

DROP TABLE [TEST_TABLE]
EXEC sp_addrolemember 'db_datawriter', 'test'
GRANT ALTER ON SCHEMA::dbo TO test;
REVOKE ALTER ON SCHEMA::dbo TO test;